package com.topboya.linker.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.topboya.linker.R;
import com.topboya.linker.model.response.CustomerByOrgIdResponse;
import java.util.List;

/**
 * GridView 适配器
 */
public class MyGridViewAdapter extends BaseAdapter {

    private Context mContext;
    private List<CustomerByOrgIdResponse.DepartmentList> departmentListList;

    public MyGridViewAdapter(Context mContext,List<CustomerByOrgIdResponse.DepartmentList> departmentListList) {
        this.mContext = mContext;
        this.departmentListList = departmentListList;
    }

    @Override
    public int getCount() {
        return departmentListList.size();
    }

    @Override
    public Object getItem(int position) {
        return departmentListList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (null == convertView) {
            convertView = View.inflate(mContext, R.layout.gridview_item, null);
        }
        TextView tvGridView = convertView.findViewById(R.id.tv_gridview);
        tvGridView.setText(departmentListList.get(position).getCusName());
        return convertView;
    }
}
